package com.dingding.special.user.account.dao.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.common.core.base.dao.impl.BaseDaoImpl;
import com.dingding.common.core.beans.special.Specialaccounttradedetail;
import com.dingding.special.user.account.dao.ISpecialAccountTradeDetailDao;
import com.dingding.special.user.account.dto.SpecialAccountTradeDetailDTO;
import com.dingding.special.user.account.sql.UserAccountSQL;

/**
 * 
 * @ClassName: SpecialAccountTradeDetailDaoImpl 
 * @Description: 专车账号交易明细DAO实现类
 * @author YHQ
 * @date 2016年8月19日 下午2:43:16
 * @since V2.4.0
 * 
 */
@Component("specialAccountTradeDetailDao")
public class SpecialAccountTradeDetailDaoImpl extends BaseDaoImpl<Specialaccounttradedetail> implements ISpecialAccountTradeDetailDao{

	private Logger log = Logger.getLogger(this.getClass());
	
	/**
	 * 
	 * @Title: getSpecialAccountTradeDetail 
	 * @Description: 根据用用户Id获取 专车账号交易明细
	 * @param userId 用户Id
	 * @author YHQ 
	 * @return List<Specialaccounttradedetail>    返回类型
	 * 
	 */
	@Override
	@Transactional(readOnly=true)
	public List<Specialaccounttradedetail> getSpecialAccountTradeDetail(String userId) {
		
		Criterion criterion = Restrictions.eq("userId", userId);
		
		try {
			return super.queryCriteriaList(criterion);
		} catch (Exception e) {
			log.error("根据用用户Id获取 专车账号交易明细时出现异常   类："+this.getClass()+" getSpecialAccountTradeDetail()", e);
		}
		
		return null;
	}
	
	/**
	 * 
	 * @Title: getSpecialAccountTradeDetail 
	 * @Description: 获取专车司机账户交易明细 
	 * @param userId 用户Id
	 * @author YHQ 
	 * @return List<SpecialAccountTradeDetailDTO>    返回类型
	 * 
	 */
	@SuppressWarnings({ "unchecked", "deprecation" })
	@Override
	@Transactional(readOnly=true)
	public List<SpecialAccountTradeDetailDTO> getSpecialAccountTradeDetail(String userId,Integer pageIndex,Integer pageSize) {
		
		try {
			return (List<SpecialAccountTradeDetailDTO>) super.listSqlFreeObject(UserAccountSQL.INCOME_AND_EXPENSESLIST, SpecialAccountTradeDetailDTO.class, userId,(pageIndex - 1) * pageSize,pageSize);
		} catch (Exception e) {
			log.error("获取专车司机账户交易明细时出现异常   类："+this.getClass()+" getSpecialAccountTradeDetail()", e);
		}
		
		return null;
	}
	
}
